import { publicRoter, provideRouter } from '@/router'
export default {
  namespaced: true,
  state: {
    routes: publicRoter
  },
  mutations: {
    setRoutes(state, routes) {
      state.routes = [...routes, ...publicRoter]
    }
  },
  actions: {
    setRoutes(context, promission) {
      const router = []
      promission.forEach((menus) => {
        router.push(
          ...provideRouter.filter((item) => {
            return item.name === menus
          })
        )
      })
      router.push({
        path: '/:catchAll(.*)',
        redirect: '/404'
      })
      context.commit('setRoutes', router)

      return router
    }
  }
}
